<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Insert title here</title>
    <#--<script type="text/javascript" src="/jquery-1.8.3.js"></script>-->
    <script src="http://pinzafile.oss-cn-shanghai.aliyuncs.com/publiccss/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
    <script>
        $(function(){
            //按钮单击时执行
            $("#button").click(function(){
                //取Ajax返回结果
                $.ajax({
                    type: "POST",
                    url: "login.json",
                    data: {email:$("#email").val(),password:$("#password").val()},
                    success: function(data){
                        if(data.ret){
                            alert(data.data);
                            window.location.href = data.data;
                            // if(data.data==1){//用户一个组，定位到首页
                            //     window.location.href = "/index.page";
                            // }else{//用户多个组，定位到
                            //     // window.location.href = "/index.page";
                            // }
                        }else{
                            $("#err").html(data.msg);
                        }
                    }
                });
            });
            $("#logout").click(function(){
                //取Ajax返回结果
                $.ajax({
                    type: "GET",
                    url: "logout",
                    success: function(data){
                        if(data.ret){
                            alert(data.data);
                            window.location.href = "/login";
                        }else{
                            $("#err").html(data.msg);
                        }
                    }
                });
            });
        });
    </script>
</head>
<body>
<div class="col-md-3 col-md-offset-4">
    <#--<form action="/user/login" method="post">-->
        <table>
            <tr>
                <td>用户名
                </td>
                <td><input type="text" name="email" id="email" value="abc@qq.com">
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" name="password" id="password" value="123456"></td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <button value="登录" id="button">登录</button>
                    <button value="登录" id="logout">退出登录</button>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <p id="err">
                    </p>
                </td>
            </tr>
        </table>
    <#--</form>-->
</div>
</body>
</html>